﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yule8xCommon.Applib;
using Yule8xCommon.Db;
using Yule8xCommon.Typelib;
using Yule8xModel;

namespace Yule8xWechat.Test
{
    public partial class IncomeIndex : System.Web.UI.Page
    {
        WxUserInfoResult wxUser;
        protected double todayincome, totalincome; // 今日收入, 累计收入
        protected System.Data.DataTable dtList;
        protected void Page_Load(object sender, EventArgs e)
        {
            int user_id = RequestUtil.GetInteger("user_id");
            if (user_id < 1)
            {
                Response.Write("请输入user_id参数");
                Response.End();
            }
            wxUser = UserModels.GetWxUserInfo(user_id);
            if (null == wxUser)
            {
                Response.Write("未登录");
                Response.End();
            }
            // 今日收入：查询用户表today_income_amount字段（查询收入表sum(金额)，create_date=今天）
            string sqlstmt = string.Format("select income_amount_today from t_user_finance_statistics where user_id={0}", wxUser.user_id);
            todayincome = double.Parse(DbFactory.Init(AppInfo.conn_yule8x_agent, true).GetValue(sqlstmt).ToString());
            // 累计收入
            sqlstmt = string.Format("select income_amount_total from t_user_finance_statistics where user_id={0}", wxUser.user_id);
            totalincome = double.Parse(DbFactory.Instance.GetValue(sqlstmt).ToString());

            sqlstmt = string.Format("select top 10 create_time, amount, remark from t_finance_transaction_details where user_id={0} and trade_type=2 order by id desc", wxUser.user_id);
            dtList = DbFactory.Instance.ExecuteDataTable(sqlstmt);
        }
    }
}